<{include file="scenter/block/header.html"}>
<div class="ucenter_t">
    <ul><li class="on">添加案例</li></ul>
    <span class="r"><a href="<{link ctl='scenter/company/case:index'}>" class="pbtn">案例管理</a></span>
</div>
<div class="ucenter_c">
<{if $group.priv.allow_case < 0}>
    <p class="tips"><span class="lock">您是【<b class="red"><{$group.group_name}></b>】没有权限添加案例</span></p>
<{/if}>
<form action="<{link ctl='scenter/company/case:create'}>" mini-form="ucenter" method="post">
<table cellspacing="0" cellpadding="0" class="form">
	<tr>
		<th><span class="red">*</span>标题：</th>
		<td><input type="text" name="data[title]" value="<{$detail.title|default:''}>" class="input w-400"/></td>
	</tr>
	<tr>
		<th>设计师：</th>
		<td>
			<select name='data[uid]' class="select w-150">				
				<option value="0">请选择</option>
				<{foreach $designers as $designer}><option value="<{$designer.uid}>"><{$designer.name}></option><{/foreach}>
			</select>
		</td>    
	</tr>
	<tr><th>小区：</th>
		<td>
			<input type="hidden" name="data[home_id]" id="select_home_id" value="0" />
			<input type="text" id="select_home_name" name="data[home_name]"  value="" class="input w-200"/>
			<a class="pbtn" id="select_home_btn"/>选择小区</a>
		</td>
	</tr>
	<tr id = 'huxing'>
		<th >户型图：</th>
		<td>
			<input type="hidden" id="select_huxing_id" value="0" name='data[huxing_id]'/>
			<input type="text" id="select_huxing_name" value="" class="input w-200" style="vertical-align:middle"/>
			<img src="###" id="select_huxing_photo" class="wh-30 none" style="vertical-align:middle"/>
			<a class="pbtn" id="select_huxing_btn" style="vertical-align:middle"/>选择户型图</a>
            	<span class="text"><a onclick="choose(1)" class="blue">切换自己上传</a></span>
            <br />
		</td>
	</tr>

    <tr id = 'upload'  style="display:none">
        <th>上传户型图：</th>
        <td>
           <input type="file" name="data[huxing]" class="input w-300" /><span class="tip-comment"></span>	<span class="text"><a onclick="choose(2)" class="blue">切换选择户型</a></span>
        </td>
    </tr>
	<{widget id="attr/form" from="zx:case"}>
	<tr><th>设计思路：</th><td><textarea name="data[intro]" class="textarea w-500"><{$detail.intro}></textarea></td></tr>
    <tr><th>SEO标题：</th><td><input type="text" name="data[seo_title]" value="<{$detail.seo_title|default:''}>" class="input w-500"/></td></tr>
    <tr><th>SEO关键字：</th><td><input type="text" name="data[seo_keywords]" value="<{$detail.seo_keywords|default:''}>" class="input w-500"/></td></tr>
    <tr><th>SEO描述：</th><td><textarea name="data[seo_description]" class="textarea w-500"><{$detail.seo_description}></textarea></td></tr> 
    <tr><th></th><td><{if $pager.audit_case<0}><input type="button" value="没有权限" disabled="disabled" class="mpbtn" /><{else}><input type="submit" value="提交数据" class="green_btn" /><{/if}></td></tr>
</table>
</form>
</div>
<script type="text/javascript">
(function(K, $){
	<{if $group.priv.allow_case < 0}>
	$("[mini-form] input,[mini-form] textarea, [mini-form] select").attr("disabled", "disabled");
	<{else}>
	$("#select_home_btn").click(function(e) {
		e.stopPropagation();
		e.preventDefault();
		var link = "<{link ctl='scenter/misc/select:home' arg0=$pager.city_id}>";
		Widget.Dialog.Select(link, "N", function(ret) {
			$("#select_home_id").val(ret[0]);
			$("#select_home_name").val(ret[1].title);
		}, {title: "选择小区", width: 500});
	});
	$("#select_huxing_btn").click(function(e) {
		e.stopPropagation();
		e.preventDefault();
		var home_id = $("#select_home_id").val();
		if (!$.isNumeric(home_id) || home_id < 1) {
			Widget.MsgBox.error("请先选择小区");
			return false;
		}
		var link = "<{link ctl='scenter/misc/select:huxing' arg0='#home_id#' arg1='1' http='base'}>";
		Widget.Dialog.Select(link.replace("#home_id#", home_id), "N", function(ret) {
			$("#select_huxing_id").val(ret[0]);
			$("#select_huxing_name").val(ret[1].title);
			$("#select_huxing_photo").attr("src", ret[1].photo).attr("photo", ret[1].photo).show();
		}, {title: "选择户型图", width: 500});
	});
	<{/if}>
})(window.KT, window.jQuery);
function choose(val){
	if(val == 1){
		$("#upload").removeAttr("style");
		$("#huxing").css('display','none'); 
	}else if(val == 2){
		$("#huxing").removeAttr("style");
		$("#upload").css('display','none'); 
	}
}
</script>
<{include file="scenter/block/footer.html"}>